<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .overlay {
            /* 用于遮挡背景 */
            position: fixed;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            background: rgba(0, 0, 0, .8);
        }

        .lightbox {
            /* 需要吸引用户注意的元素 */
            position: absolute;
            z-index: 1;
            /* [其余样式] */
            width: 200px;
            height: 100px;
            background-color: white;
            top:50%;
            left:50%;
            transform: translate(-50%,-50%);
        }
    </style>
</head>

<body>
    <div class="overlay">
        .lightbox {
            /* 需要吸引用户注意的元素 */
            position: absolute;
            z-index: 1;
            /* [其余样式] */
            width: 200px;
            height: 100px;
            background-color: white;
            top:50%;
            left:50%;
            transform: translate(-50%,-50%);
        
        <p class="lightbox">
            .overlay {
                /* 用于遮挡背景 */
                position: fixed;
                top: 0;
                right: 0;
                bottom: 0;
                left: 0;
                background: rgba(0, 0, 0, .8);
            }
        </p>
    </div>
</body>

</html>